# coding: utf-8 
import multiprocessing as mp 

def job(x):
	return x*x # 有返回值

def multicore():
	# pool = mp.Pool() # 默认是全部的核 
	pool = mp.Pool(processes=2) # 两个核
	res = pool.map(job, range(10))
	print res
	res = pool.apply_async(job, (2,))
	print res.get()
	multi_res = [pool.apply_async(job, (i,)) for i in range(10)]
	print [res.get() for res in multi_res]

if __name__ == '__main__':
	multicore()